<?php
class frm_statisticGame{
	private $args;
	function __construct($arg){
		$this->args = $arg;
	}
	function getPublish(){
		$appid = DataGameManager::getAppID();
		$gameid = $this->args["gid"];
		if(Session::isLogin()){
			$userid = Session::getID();
			$highscore = FunctionGameCenter::readUserHighScore($gameid, $userid);
			$currentscore = FunctionGameCenter::readUserCurrentScore($gameid, $userid);
			$appid = DataGameManager::getAppID();
			$key = "_score_" .$gameid;
			$keytime = "_sctime_" .$gameid;
			$currentstime = FunctionApp::getUserKey($appid,$userid,$keytime);
			$last_tour_key = "_tlastid_" .$gameid;
			$lasttour = FunctionApp::getUserKey($appid, $userid, $last_tour_key);
			$current_tour = (time()  -  (time()  % 180 ))/ 180 ;
			{ $ptnmng  = new Util\str\PatternManager( $_SESSION[ "service_dir" ]  .'/../Application/' .FunctionApp::getAppDirectory(   $appid   ).'/' .'pattern/' . ('ptn_'.  'frm_statisticGame'  ) .'.php'  );} ;
			$ptnmng->main->appid = $appid;
			$ptnmng->main->currentscore = $currentscore;
			$ptnmng->main->highscore = $highscore;
			$ptnmng->main->time = $currentstime;
			$ptnmng->main->tourid = $lasttour;
			$ptnmng->main->curtourid = $current_tour;
			return  $ptnmng->main ->publish() ;
		}else{
			return "Please login";
		}
	}
}
?>